$(function(){
	nav();
	
	
});

//导航条
function nav() {
	var nav_id = queryString("id") ;
	var navUl = $("#navList") ;
	
	$.post($.site.ctx.baseUrl + "/front/site/nav.do", function(result){
		if(result) {
			navUl.empty() ;
			navUl.append("<li><a href='"+$.site.ctx.baseUrl+"/index.jsp' class='nav-active' id='index'>ホーム</a></li>") ;
			
			$.each(result, function(i, p){
				navUl.append("<li><a id='"+p.id+"' href='"+$.site.ctx.baseUrl+"/"+p.colUrl+(p.colUrl.indexOf("?")!=-1?"&id="+p.id:"?id="+p.id)+"'>"+p.colName+"</a></li>") ;
			}); 
			
			navUl.find("li a").removeClass("nav-active")
			navUl.find("li a[id="+nav_id+"]").addClass("nav-active")
		}
	}, "JSON") ;
	
}

function changeLanguage(lan) {
	var uri = window.location.href;
	
	if(lan == "jp") {
		if(!uri.indexOf("_jp") > 0) {
			window.location.href=uri.replace("whizen", "whizen_jp");
		}
	} 
	if(lan == "cn") {
		window.location.href=uri.replace("whizen_jp", "whizen");
	}
}

/**
 * 接受URL的参数
 */
function queryString(val) {
	var uri = window.location.search;
	var re = new RegExp("" + val + "=([^&?]*)", "ig");
	return ((uri.match(re)) ? (uri.match(re)[0].substr(val.length + 1)) : null);
}


 